package com.hare.system_server.serice.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hare.common.utils.PageUtils;
import com.hare.system_api.dto.SysDictDTO;
import com.hare.system_api.po.SysDictType;
import com.hare.system_api.vo.SysDictTypeVO;
import com.hare.system_server.mapper.SysDictTypeMapper;
import com.hare.system_server.serice.SysDictTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: Hare
 * @description: 字典类型实现Service
 * @author: Hare
 * @create: 2022-11-30 21:02
 * @Version 6.0.1
 **/
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements SysDictTypeService {

    @Autowired
    SysDictTypeMapper sysDictTypeMapper;


    /**
     * 根据名称，类型，状态查询字典信息
     *
     * @param dto
     * @return
     */
    @Override
    public PageUtils<SysDictTypeVO> pageDictTypeInfo(SysDictDTO dto) {
        Page<SysDictTypeVO> sysDictTypeVOPage = sysDictTypeMapper.pageDictTypeInfo(new Page(dto.getPageIndex(), dto.getPageSize()), dto);
        if (ObjectUtil.isNotNull(sysDictTypeVOPage.getRecords())) {
            return new PageUtils<>(sysDictTypeVOPage.getRecords(), sysDictTypeVOPage.getTotal(), sysDictTypeVOPage.getSize(), sysDictTypeVOPage.getCurrent());
        }
        return new PageUtils<>();
    }
}
